(function () {
    let box = document.querySelector("#container")
    // console.log(dv);

    fetch("http://chst.vip:1234/api/getinlanddiscount")
        .then(body => body.json())
        .then(res => {
            let html1 = ""
            res.result.forEach(item => {
                html1 += `
                        <ul productid=${item.productId}>
                            <li class="li_1">
                                <a href="#">${item.productImg}</a>
                                <h3>${item.productName}</h3>
                                <p>${item.productPrice}</p>
                                <span>${item.productFrom}|${item.productTime}</span>
                            </li>
                        </ul>
                    `
            })
            // console.log(html1);
            box.innerHTML = html1

            //获取div元素，注册点击事件
            let divs = [...box.children];

            divs.forEach(div => {
                div.onclick = function () {
                    let productid = this.getAttribute("productid")
                    // console.log(productid);

                    //跳转当前详情页面
                    location.href = `../pages/inlanddiscount2.html?productid=${productid}`
                }
            })

        })
})()